// 04jyhs/shoppingMallAdmin/MallOrderAdmin/MallOrderAdmin.js
var co = require('../../../resource/js/common.js')
var app = getApp()
var _this, _data,_page
Page({
   data: {
      orderStatusName: [
         "待付款", 
         "待发货", 
         "已取消", 
         "已评价", 
         "已发货", 
         "退款", 
         "已完成"
      ],
      // 分类商品数据
      OrderList: [],
      // 屏幕高度
      win_h: '',
      idx:0
   },
   //进入页面加载
   onLoad: function() {
      _this = this
      _data = this.data
      _page = 1
      this.setData({
         win_h: wx.getSystemInfoSync().windowHeight
      })
      _this.getGoodsList(1)
   },
   //隐藏页面的时候清空数据
   onHide: function() {
   },

   //返回进入自动更新数据
   onShow: function() {
      
   },
   onPullDownRefresh: function () {
      var status = _data.idx + 1
      _this.getGoodsList(status)
   },
   //获取商品
   getGoodsList: function(status) {
      co.getMealApi('jyhs/Ordmg/getAllsOrderList', {
         Order_Status: status,
         page: _page
      }, function(res) {
            if (res.code == 0) {
               console.log("【获取分类商品数据】===", res.data)
               _this.setData({
                  OrderList: res.data
               })
               _page++
            } else {
               _this.setData({
                  OrderList: res.data
               })
               co.toastAllText(res.msg)
            }
      })
   },
   //商品分类点击事件
   cateClick: function (e) {
      var index1 = Number(e.currentTarget.id)
      _this.setData({
         idx: index1
      })
      var index = index1 + 1
      _page = 1
      _this.getGoodsList(index)
   },
   //发货事件
   sendOutGoods(e) {
      var index = e.currentTarget.id
      var orders = JSON.stringify(_data.OrderList[index])
      wx.navigateTo({
         url: '/04jyhs/shoppingMallAdmin/MallOrderAdmin/SendOutGoods/SendOutGoods?orders=' + orders,
      })
   },
   //跳转至订单详情
   goToMallOrderDetail(e) {
      var index = e.currentTarget.id
      var Order_ID = _data.OrderList[index].Order_ID
      wx.navigateTo({
         url: '/04jyhs/shoppingMallAdmin/MallOrderAdmin/MallOrderDetail/MallOrderDetail?orderID=' + Order_ID,
      })
   },
})